package com.neusoft.databus.core.converter;

import org.springframework.stereotype.Component;

import com.neusoft.bizcore.web.dto.AbstractConverter;
import com.neusoft.databus.common.dto.DictionaryDTO;
import com.neusoft.databus.common.model.Dictionary;

/**
 * 资源转换器
 *
 * @author sunchf
 * @date 2018年12月24日 上午9:44:01
 */
@Component
public class DictionaryConverter extends AbstractConverter<Dictionary, DictionaryDTO> {

    @Override
    public Dictionary toModel(DictionaryDTO dto) {
        return null;
    }

    @Override
    public DictionaryDTO toDTO(Dictionary model, boolean forListView) {
        final DictionaryDTO dto = new DictionaryDTO();
        dto.setId(model.getId());
        dto.setCode(model.getCode());
        dto.setText(model.getText());
        dto.setSort(model.getSort());
        dto.setDictionaryType(model.getDictionaryType());
        if (null != model.getParent()) {
            dto.setParent(model.getParent().getId());
        }
        return dto;
    }

}
